package cn.jinjie.day04.test04;

public class Test01 {
    public static void main(String[] args) {

        useStuFactory(new IStudentFactory() {
            @Override
            public Student getStudent(String name, int age) {
                return new Student(name, age);
            }
        });
        //lambda
        useStuFactory((name, age) -> new Student(name, age));
        //方法引用
        useStuFactory(Student::new);

    }

    //使用学生工厂的方法 传入学生工厂接口的实现类对象
    public static void useStuFactory(IStudentFactory factory) {
        //调用getStudent 返回一个学生对象
        Student s = factory.getStudent("小明", 30);
        System.out.println(s.getName() + "--" + s.getAge());
    }
}
